package com.hehe.conversion.hehemiddleware.controller;

import com.alibaba.fastjson.JSONObject;
import com.hehe.conversion.hehemiddleware.model.req.old.EsbXmlRequest;
import com.hehe.conversion.hehemiddleware.model.resp.esbxml.EsbXmlResponse;
import com.hehe.conversion.hehemiddleware.service.EsbXmlRequestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController("/xml")
@Slf4j
public class EsbXmlController {
    @Autowired
    private EsbXmlRequestService esbXmlRequestService;

    @PostMapping(value = "/cci_ai/service/v1/id_card", consumes = "application/xml", produces = "application/xml")
    public EsbXmlResponse idCard(@RequestBody EsbXmlRequest serviceRequest) {
        log.info(" EsbXmlController idCard request:{}", JSONObject.toJSONString(serviceRequest));
        return esbXmlRequestService.handleIdCardRequest(serviceRequest);
    }
    @PostMapping(value = "/ai/service/v1/business_license", consumes = "application/xml", produces = "application/xml")
    public EsbXmlResponse businessLicense(@RequestBody EsbXmlRequest serviceRequest) {
        log.info(" EsbXmlController businessLicense request:{}", JSONObject.toJSONString(serviceRequest));
        return esbXmlRequestService.handleBusinessLicenseRequest(serviceRequest);
    }
}
